home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 2
/
SPACE - Library 2 - Volume 1.iso
/
apps
/
356
/
applic
/
getflsz.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1989-02-16
|
2KB
|
54 lines
PROCEDURE GetFileSize(FileName : path_name;
VAR NbrBytesInFile : long_integer);
{Get the length of a file in bytes. The file name in a standard Pascal
form is provided as a parameter.}
TYPE
pack14 = PACKED ARRAY[1..14] OF char;
cstring = PACKED ARRAY[1..80] OF char;
DTA_Type = PACKED RECORD
reserved : PACKED ARRAY[0..19] OF byte;
resvd : byte;
Attribute: byte;
Time : integer;
Date : integer;
FileSize : long_integer;
F_Name : pack14;
END {record};
S80 = string[80];
VAR
Addr : DTA_Type;
Attributes : byte;
S2 : s80;
C_FileName : cstring;
Status : integer;
PROCEDURE StrToC_String(Name1 : Path_Name; VAR Name2 : CString);
{Convert a Pascal string to a null terminated character array}
VAR i,l : integer;
BEGIN
L := LENGTH(Name1);
FOR i := 1 TO L DO
Name2[i] := Name1[i];
Name2[L+1] := CHR(0);
END {strtoc_string};
PROCEDURE SetDTA(VAR Addr : DTA_Type);
GEMDOS($1A);
FUNCTION SearchFirst(VAR FileName : cstring;
Attributes : integer)
: integer;
GEMDOS($4E);
BEGIN {getfilesize}
SetDTA(Addr);
StrToC_String(FileName,C_FileName);
Attributes := $07;
Status := SearchFirst(C_FileName,Attributes);
IF Status <> 0
THEN
WriteLn('Error on getting file size from OS. Status:',Status);
NbrBytesInFile := Addr.FileSize;
END {getfilesize};